package thread.biz;

import thread.util.MixUtils;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

/**
 * Delivery Order Service
 */
public class DOrderService {
    private Map<Integer, DOrder> doMap = new HashMap<>();
    private Random random = new Random();

    public DOrderService() {
        for (int id = 1; id <= MixUtils.IDMAX; id++)
            doMap.put(id, DOrder.builder().id(id).deliveryInfo("派送订单" + id).build());
    }

    public DOrder getDOrder(int id) {
        MixUtils.sleepMs(100/* + random.nextInt(1000)*/); // 模拟延时 100ms
        return doMap.get(id);
    }
}
